package com.sjzxywlkj.cplife.xywuye.api;

import com.sjzxywlkj.cplife.utils.RequestResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@Api(tags = "测试接口类")
@RestController
@RequestMapping(value = "/api/v1/test")
public class TestRest extends BaseRest {


    @ApiOperation(value = "获取数据测试接口", notes = "Get Rest接口的Demo方法", produces = "application/json")
    @ApiImplicitParam(name = "userId", value = "用户Id", required = true, dataType = "String", paramType = "query", defaultValue = "1234555SHA")
    @GetMapping(value = "/get_user")
    public RequestResult get_user(@RequestHeader(name = "token") String token,
                                  @RequestParam("userId") String userId) {
        logger.info("获取用户信息 start....");

//        UserMapper userMapper = SpringContextHandler.getBean(UserMapper.class);
//        UserModel user = userMapper.getById(userId);
//
//        if (user == null) {
//            return RequestResult.generate(12, "未获得user_id = " + userId + "的用户记录");
//        } else {
//            return RequestResult.generate(0, "获取成功", user);
//        }
        return null;
    }

    @PostMapping(value = "/save_user")
    public RequestResult save_user(@RequestHeader(name = "Authorization", defaultValue = "token") String token,
                                   @RequestParam("userId") String userId) {
        logger.info("获取用户信息 start....");

//        UserMapper userMapper = SpringContextHandler.getBean(UserMapper.class);
//        logger.error("userMape is null =>" + (userMapper == null));
//
//        Map<String, Object> data = new HashMap();
//        data.put("username", "崔鹏宇");
//        data.put("年龄", "41");
//        data.put("detail", "本对象仅用于测试演示Get类型Rest方法");
//        RequestResult result = RequestResult.generate(0, "已经成功了。", data);
//        return result;
        return null;
    }

}
